# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  # Pick a unique cookie name to distinguish our session data from others'
  session :session_key => '_rod_session_id'
  
  private
  def authorize
    unless session[:user_id]
      session[:original_uri] = request.request_uri
      flash[:notice] = "Por favor, autentique-se!<br/><br/>"
      redirect_to(:controller => "../login",:action => "login")
    end
  end

  def authorize_admin
    unless (session[:user_id] && session[:is_admin] == true)
      session[:original_uri] = request.request_uri
      flash[:notice] = "Por favor, autentique-se!<br/><br/>"
      redirect_to(:controller => "../login",:action => "login")
    end
  end  
end
